<?php
namespace App\Traits;

use App\Models\FakeDetail;
use App\Models\FakeList;
use Illuminate\Http\Request;

Trait Trait40_42 {

    public function fireList()
    {
        $data = FakeList::select(['id', 'name', 'status'])->wherein('id', [66, 67, 68])->get();
        $responseJson = [
            'code' => 200,
            'message' => '',
            'data' => $data
        ];
        return response()->json($responseJson);
    }

    public function fireDetail(Request $request)
    {
        $val = $request->validate([
            'id' => 'required|integer'
        ]);
        $data = FakeDetail::select(['extra_data'])->where(['f_id' => 66])->get();
        $responseJson = [
            'code' => 200,
            'message' => '',
            'data' => $data
        ];
        return response()->json($responseJson);
    }

    public function fireAlarmDetail()
    {
        $data = FakeDetail::with(['fakelist' => function ($query) {
            $query->select('id', 'name');
        }])->select(['f_id', 'message'])->wherein('id', [62])->get();
        $responseJson = [
            'code' => 200,
            'message' => '',
            'data' => $data
        ];
        return response()->json($responseJson);
    }

}
